package chan.project.smartlawmodel.dto.lawregulation;

import chan.project.smartlawmodel.dto.instrument.InstrumentMessage;
import chan.project.smartlawmodel.entity.LawRegulation;
import chan.project.smartlawmodel.entity.LawRegulationInvokeLog;
import chan.project.smartlawmodel.entity.TemLawRegulationInvokeLog;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.Date;

@Data
public class LawRegulationMessage {
    /**
     * 主键ID
     */
    private Long id;

    /**
     * 法规名称
     */
    private String title;

    /**
     * 文号（如“法令〔2020〕1号”）
     */
    private String regNumber;

    /**
     * 颁布日期
     */
    private Date promulgationDate;

    /**
     * 实施日期
     */
    private Date effectiveDate;

    /**
     * 废止日期（若未废止，则为 NULL）
     */
    private Date abolishDate;

    /**
     * 状态：1 草稿；2 生效；0 废止；3 被其它法规取代
     */
    private Integer status;

    /**
     * 版本号
     */
    private String version;

    /**
     * 目录
     */
    private String directory;

    /**
     * 法规全文
     */
    private String content;

    /**
     * 创建人
     */
    private String createdBy;

    /**
     * 创建时间
     */
    private Date createdAt;

    /**
     * 最后修改人
     */
    private String updatedBy;

    /**
     * 最后修改时间
     */
    private Date updatedAt;

    /**
     * 调用时间
     */
    private Date sendTime;

    /**
     * 转换为LawRegulationMessage
     * @param lawRegulation
     * @param sendTime
     * @return
     */
    public static LawRegulationMessage toLawRegulationMessage(LawRegulation lawRegulation,Date sendTime) {
        LawRegulationMessage lawRegulationMessage = new LawRegulationMessage();
        BeanUtils.copyProperties(lawRegulation, lawRegulationMessage);
        lawRegulationMessage.setSendTime(sendTime);
        return lawRegulationMessage;
    }

    public LawRegulationInvokeLog toLawRegulationInvokeLog(LawRegulationMessage lawRegulationMessage) {
        LawRegulationInvokeLog lawRegulationInvokeLog = new LawRegulationInvokeLog();
        lawRegulationInvokeLog.setRegulationId(lawRegulationMessage.getId());
        lawRegulationInvokeLog.setSendTime(lawRegulationMessage.getSendTime());
        return lawRegulationInvokeLog;
    }

    public TemLawRegulationInvokeLog toTemLawRegulationInvokeLog(LawRegulationMessage lawRegulationMessage) {
        TemLawRegulationInvokeLog lawRegulationInvokeLog = new TemLawRegulationInvokeLog();
        lawRegulationInvokeLog.setRegulationId(lawRegulationMessage.getId());
        lawRegulationInvokeLog.setTitle(lawRegulationMessage.getTitle());
        lawRegulationInvokeLog.setSendTime(lawRegulationMessage.getSendTime());
        return lawRegulationInvokeLog;
    }
}
